<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <input type="text" id="number1">
    <input type="text" id="number2">
    <button onclick="sum()">求和</button>
    <p>结果<span id="result"></span></p>

    <script>
        let num1Tag = document.getElementById("number1")
        let num2Tag = document.getElementById("number2")
        let resultTag = document.getElementById("result")
        console.log(num1Tag);
        console.log(num2Tag);
        console.log(resultTag);
        let num1 = num1Tag.value 
        let num2 = num2Tag.value
        
        function sum(){
            let num1 = num1Tag.value - 0
            let num2 = num2Tag.value - 0
            console.log(num1);
            console.log(num2);
            let result = num1+ num2
            resultTag.innerHTML = result
        }
    </script>
</body>
</html>